package com.yict.csms.resourceplan.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.yict.common.service.impl.BaseServiceImpl;
import com.yict.csms.resourceplan.dao.INGenDataDao;
import com.yict.csms.resourceplan.dao.IShipPlanDao;
import com.yict.csms.resourceplan.entity.ShipPlan;
import com.yict.csms.resourceplan.service.IShipPlanService;
import com.yict.csms.system.entity.DataDict;
import com.yict.csms.system.service.IDataDictService;
import com.yict.csms.system.util.DictionaryUtils;

@Service("shipPlanService")
public class ShipPlanServiceImpl extends BaseServiceImpl<ShipPlan, Long, IShipPlanDao> implements IShipPlanService {
	private INGenDataDao nGenDataDao;
	private IDataDictService dictservice;
	
	/**
	 * 创建计费记录
	 * 查找已派更确认但没有计费的数据进行计费
	 * @throws Exception 
	 */
	@Transactional(readOnly = false,rollbackFor = {Exception.class})
	public void createCost() throws Exception{
		DataDict dict = dictservice.findByCode(DictionaryUtils.DICT_CODE_SHIPSTATUS04);
		String hql = "from ShipPlan t where t.sendStatus = :sendStatus and t.status <> :status";
		Map<String,Object> map = new HashMap<String,Object>();
		map.put("sendStatus", dict.getDictid());
		map.put("status", "F");
		List<ShipPlan> list = this.getBaseDao().list(hql, map, 0, 0);
		for(ShipPlan sp : list){
			//ShipNGen ship = sp.getShip();
			//NGenData ngenData = nGenDataDao.findNGenData(ship.getShipName(), ship.getVoyage());
		}
	}

	@Resource(name = "shipPlanDao")
	@Override
	public void setBaseDao(IShipPlanDao baseDao) {
		super.setBaseDao(baseDao);
	}

	public INGenDataDao getnGenDataDao() {
		return nGenDataDao;
	}

	@Resource(name = "nGenDataDao")
	public void setnGenDataDao(INGenDataDao nGenDataDao) {
		this.nGenDataDao = nGenDataDao;
	}

	public IDataDictService getDictservice() {
		return dictservice;
	}
	
	@Resource(name = "dataDictService")
	public void setDictservice(IDataDictService service) {
		this.dictservice = service;
	}
}
